<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Chapter&nbsp;19.&nbsp;可插入架构</title>
    <link rel="stylesheet" href="css/html.css" type="text/css">
    <meta name="generator" content="DocBook XSL Stylesheets V1.65.1">
    <link rel="home" href="index.html" title="JBoss jBPM 3.1">
    <link rel="up" href="index.html" title="JBoss jBPM 3.1">
    <link rel="previous" href="tdd.html" title="Chapter&nbsp;18.&nbsp;TDD for workflow">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
    <table width="100%" summary="Navigation header">
        <tr>
            <th colspan="3" align="center">Chapter&nbsp;19.&nbsp;可插入架构</th>
        </tr>
        <tr>
            <td width="20%" align="left"><a accesskey="p" href="tdd.html">Prev</a>&nbsp;</td>
            <th width="60%" align="center">&nbsp;</th>
            <td width="20%" align="right">&nbsp;</td>
        </tr>
    </table>
    <hr>
</div>
<div class="chapter" lang="cn">
    <div class="titlepage">
        <div>
            <div><h2 class="title"><a name="pluggable"></a>Chapter&nbsp;19.&nbsp;可插入架构</h2></div>
        </div>
        <div></div>
    </div>
    <p>The functionality of jBPM is split into modules. Each module
        has a definition and an execution (or runtime) part. The central
        module is the graph module, made up of the
        <tt class="literal">ProcessDefinition</tt> and the <tt class="literal">ProcessInstance</tt>.
        The process definition contains a graph and the process instance represents
        one execution of the graph. All other functionalities of jBPM are grouped into
        optional modules. Optional modules can extend the graph module with extra
        features like context (process variables), task management, timers, ...</p>

    <div class="figure"><a name="pluggable.architecture.image"></a>

        <div class="mediaobject" align="center"><img src="images/pluggable.architecture.gif" align="middle"
                                                     alt="The pluggable architecture"></div>
        <p class="title"><b>Figure&nbsp;19.1.&nbsp;The pluggable architecture</b></p></div>
    <p>The pluggable architecture in jBPM is also a unique mechanism to
        add custom capabilities to the jBPM engine. Custom process definition information
        can be added by adding a <tt class="literal">ModuleDefinition</tt> implementation to the process definition.
        When the <tt class="literal">ProcessInstance</tt> is created, it will create an instance for every
        <tt class="literal">ModuleDefinition</tt> in the <tt class="literal">ProcessDefinition</tt>. The <tt
            class="literal">ModuleDefinition</tt> is used
        as a factory for <tt class="literal">ModuleInstances</tt>.
    </p>

    <p>The most integrated way to extend the process definition information is
        by adding the information to the process archive and implementing a
        <tt class="literal">ProcessArchiveParser</tt>. The <tt class="literal">ProcessArchiveParser</tt>
        can parse the information added to the process archive, create your custom
        <tt class="literal">ModuleDefinition</tt> and add it to the <tt class="literal">ProcessDefinition</tt>.</p><pre
        class="programlisting">public interface ProcessArchiveParser {

  void writeToArchive(ProcessDefinition processDefinition, ProcessArchive archive);
  ProcessDefinition readFromArchive(ProcessArchive archive, ProcessDefinition processDefinition);

}</pre>
    <p>To do its work, the custom <tt class="literal">ModuleInstance</tt> must be notified of
        relevant events during process execution. The custom <tt class="literal">ModuleDefinition</tt>
        might add <tt class="literal">ActionHandler</tt> implementations upon events in the process that
        serve as callback handlers for these process events.</p>

    <p>Alternatively, a custom module might use AOP to bind the custom instance into the
        process execution. JBoss AOP is very well suited for this job since it is mature, easy
        to learn and also part of the JBoss stack.</p></div>
<div class="navfooter">
    <hr>
    <table width="100%" summary="Navigation footer">
        <tr>
            <td width="40%" align="left"><a accesskey="p" href="tdd.html">Prev</a>&nbsp;</td>
            <td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td>
            <td width="40%" align="right">&nbsp;</td>
        </tr>
        <tr>
            <td width="40%" align="left" valign="top">Chapter&nbsp;18.&nbsp;TDD for workflow&nbsp;</td>
            <td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
            <td width="40%" align="right" valign="top">&nbsp;</td>
        </tr>
    </table>
</div>
</body>
</html>